package com.cyc.controller;

import com.alibaba.fastjson.JSON;
import com.cyc.entity.OrderDetail;
import com.cyc.service.OrderDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("orderdetail")
public class OrderDetailController {

    @Autowired
    OrderDetailService orderDetailService;

    @RequestMapping("all")
    @ResponseBody
    public String all(Integer page,Integer limit,String serialnumber,String loginname){
        Map<String, Object> map=new HashMap<>();
        Map<String, Object> sss=new HashMap<>();
        sss.put("serialnumber",serialnumber);
        sss.put("loginname",loginname);
        PageHelper.startPage(page,limit);
        List<OrderDetail> list = orderDetailService.selectAll(sss);
        PageInfo pageInfo=new PageInfo(list);
        map.put("code",0);
        map.put("msg","成功");
        map.put("count",pageInfo.getTotal());
        map.put("data",list);
        return JSON.toJSONString(map);
    }

}
